package com.ch.demo1;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class demo8 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(),9999);


        OutputStream outputStream = socket.getOutputStream();

        InputStream inputStream = socket.getInputStream();

        outputStream.write("ip:127.0.0.1,port:9999".getBytes());

        socket.shutdownOutput();
        byte[] b = new byte[1024];
        int str;
        while((str = inputStream.read(b)) != -1){
            System.out.println(new String(b,0,str));
        }

        socket.close();
        inputStream.close();
        outputStream.close();
    }
}
